<%@page import="edu.uit.se.laps.web.model.SanPham"%>
<%@page import="edu.uit.se.laps.web.model.CTDonHang"%>
<%@page import="edu.uit.se.laps.web.model.TaiKhoan"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!-- pageEncoding="UTF-8"%> -->
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page
	import="edu.uit.se.laps.web.*,edu.uit.se.laps.web.controller.*, java.net.*,java.text.*,java.util.*"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body,input {
	font-family: Calibri, Arial;
}

table#contact {
	border-collapse: collapse;
	width: 550px;
}

th {
	height: 40px;
	background-color: #ffee55;
}
ul{
	list-style-type: none;
}
ul a{
	width: 120px;
	display: inline-block;
}
textarea{
	max-width: 400px;
	width: 300px;
}

.taotk{
	width: 120px;
	height: 40px;
	background: red;
	color: white;
	border: none;
	font-size: 18px;
	cursor: pointer;
	text-decoration: none;
	display: inline;
}
.taotk:hover{
	background: #6B0000;
}

.tt_taikhoan{
	margin-bottom: 60px;
	width: 100%;
}
table{
	border-collapse: collapse;
	width: 100%;
}
table tr{
	border-collapse: collapse;
}
</style>
<title>myLife - Giỏ hàng</title>

<s:head />
<!-- the s:head de thong bao loi validation -->
</head>
<body>
<tiles:insertTemplate template="Template.jsp">
	<tiles:putAttribute name="focusbody">
	
	<%
		ShoppingCart cart = (ShoppingCart) session
				.getAttribute("ShoppingCart");

		if (cart == null) {
			cart = new ShoppingCart();
			session.setAttribute("ShoppingCart", cart);
		}
	
		List spList = cart.getspList();
		
		List ctdhList = cart.getcTDHList();
		if (ctdhList.size() != 0){
			
	%>

	<h1>CHI TIẾT GIỎ HÀNG</h1>
	<a class="taotk" href="showfashion">Tiếp tục mua hàng</a>
	<!-- 	<a href="showSP">Show sp</a> -->

	<h2>Thông tin sản phẩm</h2>
	
	
		<table id="ctdonhang" border="1">
		<tr>
<!-- 			<th>Id chi tiết đơn hàng</th> -->
<!-- 			<th>Id đơn hàng</th> -->
			<th>Sản phẩm</th>
			<th>Đơn giá</th>
			<th>Số Lượng</th>
			<th>Thành tiền</th>
			<th>Xóa sản phẩm</th>
			<%
			for (int i = 0; i < ctdhList.size(); i++) {
				CTDonHang ctdh = (CTDonHang) ctdhList.get(i);
			%>
		</tr>		
			<tr>
<%-- 				<td><%= ctdh.getIdCTDH() %></td> --%>
<%-- 				<td><%= ctdh.getIdDH() %></td> --%>
				<%
					for (int j = 0; j < spList.size(); j++){
						SanPham spTemp = (SanPham) spList.get(j);
						if (ctdh.getIdSP() == spTemp.getIdSP()) {
				%>
<%-- 				<td><%= spTemp.getTenSP() %></td> --%>
				<td><a href="detail?idsp=<%=ctdh.getIdSP()%> "><%= spTemp.getTenSP() %></a></td>
				<%
						}
					}
				%>
				
				<td><%= ctdh.getDonGia() %></td>
				<td><%= ctdh.getSoLuong() %></td>
				<td><%= ctdh.getThanhTien() %></td>
				<td><a href="deleteItemCart?idsp=<%=ctdh.getIdSP()%>">
						Xóa </a> <%-- 				<td><a href="showupdate?idsp=<s:property value="idSP"/>">Update</a></td> --%>
				</td>
			</tr>
		<%
			}
		%>
	</table>
	<%
		}
	%>
	
	
<!-- 	<table id="ctdonhang" border="1"> -->
<!-- 		<tr> -->
<!-- 			<th>Id chi tiết đơn hàng</th> -->
<!-- 			<th>Id đơn hàng</th> -->
<!-- 			<th>Id sản phẩm</th> -->
<!-- 			<th>Đơn giá</th> -->
<!-- 			<th>Số Lượng</th> -->
<!-- 			<th>Thành tiền</th> -->
<!-- 			<th>Xóa sản phẩm</th> -->
<!-- 		</tr> -->
<%-- 		<s:iterator value="ctdhList" var="ctdh"> --%>
<!-- 			<tr> -->
<!-- 				<td><div> -->
<%-- 						<s:property value="idCTDH" /> --%>
<!-- 					</div></td> -->
<%-- 				<td><s:property value="idDH" /></td> --%>
<%-- 				<td><s:property value="idSP" /></td> --%>
<%-- 				<td><s:property value="donGia" /></td> --%>
<%-- 				<td><s:property value="soLuong" /></td> --%>
<%-- 				<td><s:property value="thanhTien" /></td> --%>
<%-- 				<td><a href="deleteItemCart?idsp=<s:property value="idSP"/>"> --%>
<%-- 						Xóa </a> 				<td><a href="showupdate?idsp=<s:property value="idSP"/>">Update</a></td> --%>
<!-- 				</td> -->
<!-- 			</tr> -->
<%-- 		</s:iterator> --%>
<!-- 	</table> -->
	
	
	
	
	
	
	
	
	<br>
	<a class="taotk" href="checkout">Thanh toán</a>
	<h2>Số tiền phải trả: <a style="color: red; font-size: 30px">${sumMoney}</a> đồng</h2>
	
	

		</tiles:putAttribute>
	
	</tiles:insertTemplate>
</body>
</html>